#include <stdio.h>

// 求 1！+3！+5！+……+N!的值。N 由键盘输入，且为奇数

int main()
{
    int n, i;
    long temp, sum;

    printf("enter a odd number:");
    scanf("%d", &n);
    if (n < 0 || n % 2 == 0)
    {
        printf("[Err] [%d] is not odd number\n", n);
        return 0;
    }

    // inside 1
    sum = 1;
    for (i = 3, temp = 1; i <= n; i += 2)
    {
        temp *= i * (i - 1);
        sum += temp;
    }
    printf("1!+3!+..+%d! = %d\n", n, sum);
}